<!DOCTYPE html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>体检信息
            <small>信息录入</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>体检信息</el-breadcrumb-item>
            <el-breadcrumb-item>信息录入</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="手机号/姓名" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号" width="50px"></el-table-column>
                <el-table-column prop="memberName" label="姓名" align="center" width="100px"></el-table-column>
                <el-table-column prop="phoneNumber" label="手机号" align="center" width="110px"></el-table-column>
                <el-table-column label="性别" align="center" width="70px">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sex == '0' ? '不限' : scope.row.sex == '1' ? '男' : '女'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="age" label="年龄" align="center" width="70px"></el-table-column>
                <el-table-column prop="setmealName" label="套餐名称" align="center" width="120px"></el-table-column>
                <el-table-column prop="orderType" label="预约类型" align="center" width="110px"></el-table-column>
                <el-table-column prop="orderDate" label="预约日期" align="center" width="110px"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleWrite(scope.row)">录入体检信息</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 体检信息弹层 -->
            <div class="add-form">
                <el-dialog title="体检信息" :visible.sync="dialogFormVisible">
                    <template>
                        <div>
                            <el-form label-position="right" label-width="100px">
                                <el-row v-for="checkgroup in checkgroupList">
                                    {{checkgroup.checkgroupName}}
                                    <el-row v-for="checkitem in checkgroup.checkitemMap">
                                        <el-col :span="12">
                                            <el-form-item>
                                                {{checkitem.checkitemName}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item>
                                                <el-input type="text" v-model="checkitem.content"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-row>
                            </el-form>
                        </div>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button type="primary" @click="handleUpdate()">更新</el-button>
                        <el-button type="primary" @click="handleComplete()">完成</el-button>
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<!--<script src="../plugins/datapicker/datePicker.js"></script>-->
<script src="../plugins/healthmobile.js"></script>


<script>
    var vue = new Vue({
        el: '#app',
        data: {
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {},//表单数据
            checkgroupList: {},
            dialogFormVisible: false,//增加表单是否可见
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();//VUE对象初始化完成后调用分页查询方法，完成分页查询
        },
        methods: {
            //更新体检信息
            handleUpdate(){
                axios.post("/checkinfo/update.do",this.checkgroupList).then((res)=>{
                    if(res.data.flag){
                        this.$message({
                            type:"success",
                            message:"体检信息更新成功"
                        })
                        this.dialogFormVisible=false;
                    }else{
                        this.$message.error("体检信息更新失败");
                    }
                })
            },
            //完成体检信息
            handleComplete(){
                axios.post("/checkinfo/complete.do",this.checkgroupList).then((res)=>{
                    if(res.data.flag){
                        this.$message({
                            type:"success",
                            message:"体检已完成"
                        })
                        this.dialogFormVisible=false;
                        this.findPage();
                    }else{
                        this.$message.error("体检完成失败");
                    }
                })
            },
            //分页查询
            findPage() {
                //发送ajax请求，提交分页相关请求参数（页码、每页显示记录数、查询条件）
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString
                };
                axios.post("/checkinfo/findPage.do", param).then((res) => {
                    //解析Controller响应回的数据，为模型数据赋值
                    this.pagination.total = res.data.total;
                    this.dataList = res.data.rows;
                });
            },
            // 重置表单
            resetForm() {
                this.formData = {};//重置数据
            },
            //录入体检信息按钮
            handleWrite(row) {
                //弹出录入信息窗口
                this.dialogFormVisible = true;
                this.resetForm();
                //根据orderId查询检查组和检查项及内容信息
                axios.post("/checkinfo/findAllCheckgroupAndCheckitem.do?orderId=" + row.id).then((res) => {
                    if (res.data.flag){
                        this.checkgroupList = res.data.data;
                    }else {
                        this.$message.error("检查组和检查项查询失败");
                    }
                })
            },
            //切换页码
            handleCurrentChange(currentPage) {
                //设置最新的页码
                this.pagination.currentPage = currentPage;
                //重新调用findPage方法进行分页查询
                this.findPage();
            },

        }
    })
</script>


</html>